package com.jn.news.ui;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;

import com.jn.news.R;
import com.jn.news.utils.Constant;
import com.jn.news.utils.SPUtils;
import com.jn.news.utils.StatusBarUtils;

public class MyActivity extends AppCompatActivity implements View.OnClickListener {

    private LinearLayout llPerson;
    private LinearLayout llCollection;
    private TextView tvQuit;
    private ImageView ivBack;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        StatusBarUtils.with(this).init3(2, 102);
        setContentView(R.layout.activity_my);
        initView();
        initData();

    }



    private void initView() {
        llPerson = findViewById(R.id.ll_person);
        llCollection = findViewById(R.id.ll_collection);
        tvQuit = findViewById(R.id.tv_quit);
        ivBack = findViewById(R.id.toolbar_left);
    }
    private void initData() {
        llPerson.setOnClickListener(this);
        llCollection.setOnClickListener(this);
        tvQuit.setOnClickListener(this);
        ivBack.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        if(v.getId() == R.id.ll_person){
            startActivity(new Intent(this, PersonalInfoActivity.class));
        } else if (v.getId() == R.id.ll_collection) {
            startActivity(new Intent(this, MyCollectionActivity.class));
        } else if (v.getId() == R.id.tv_quit) {
            SPUtils.put(this, Constant.USERNAME,"");
            SPUtils.put(this, Constant.PASSWORD,"");
            SPUtils.put(this, Constant.USERID, 0);
            Intent intent = new Intent(this, MainActivity.class);
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
            startActivity(intent);
            finish();
        } else if (v.getId() == R.id.toolbar_left) {
            finish();
        }
    }
}